import React, { Component } from 'react';
import {Link } from 'react-router-dom';
import {Row,Col,List} from 'antd';
import style from './link.less';
import $ from 'jquery'
import {getCurrentHostPath} from './util/utils';
var moment = require('moment');

export default class LinkModal extends Component{
    constructor() {
        super();
        this.state={
            visible: false,
            dataSource:[{
                name:'监管平台',
                url:'http://www.baidu.com'
            }]
        }
    }
    componentDidMount(){
        $('#link-area').mCustomScrollbar({
            theme:"light-thin"
        });
    }
    projectClick = (name,linkurl) => {
        if(linkurl.indexOf('intelligent') === -1){
            window.location.replace(linkurl)
        }else{
            window.location.replace(getCurrentHostPath()+linkurl)
        }
       
    }   
    render(){
        const {dataSource,visible} = this.props
        let display = visible ? "visible" : 'hidden'
        return(
            <div>
                <div className={style.htmlContainerBorder} style={{position:'absolute',height:'400px',right:'54px',top:'100px',zIndex:9999,visibility:display}}>
                    <div id="link-area" className={style.linkLayerstyle_out}>
                        <List
                        dataSource={dataSource}
                        renderItem={item => (
                        <List.Item className={style.listItem} onClick={()=>{this.projectClick(item.name,item.url)}}>
                            <Row style={{width:'100%',overflow:'hidden'}}>
                                {item.name}
                            </Row>
                        </List.Item>)}
                    />
                    </div>
                </div>
            </div>
        )
    }
}
